using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace Geometry
{
    /// <summary>
    /// This is a simple point class. It could be improved later when needed.
    /// </summary>
    public class Point
    {
    	/// <summary>
    	/// X offset of the point
    	/// </summary>
        public double X;
    	/// <summary>
    	/// X offset of the point
    	/// </summary>
        public double Y;
    	/// <summary>
    	/// Z offset of the point
    	/// </summary>
        public double Z;

        /// <summary>
        /// Simple constructor for point class which sets the x,y,z values to both 0
        /// </summary>
        public Point()
        {
            X = 0.0;
            Y = 0.0;
            Z = 0.0;
        }
		/// <summary>
		/// 2D constructor, which sets X,Y offsets and Z=0
		/// </summary>
		/// <param name="x">X offset</param>
		/// <param name="y">Y offset</param>
        public Point(double x, double y)
        {
            X = x;
            Y = y;
            Z = 0.0;
        }
		/// <summary>
		/// 3D constructor, which sets both X,Y,Z offsets
		/// </summary>
		/// <param name="x">X offset</param>
		/// <param name="y">Y offset</param>
		/// <param name="z">Z offset</param>
        public Point(double x, double y, double z)
        {
            X = x;
            Y = y;
            Z = z;
        }

		/// <summary>
		/// An operator for creating a colorPoint object.
		/// </summary>
		/// <remarks>
		/// This operator is designed for use with PointCloud Class, which is written for Raster.Resampling namespace.
		/// </remarks>
		/// <param name="p">Point Object</param>
		/// <param name="c">Color Object</param>
		/// <returns>A ColoredPoint Object</returns>
        public static ColoredPoint operator +(Point p, Color c)
        {
            return new ColoredPoint(p.X, p.Y, p.Z, c.R, c.G, c.B);
        }

		/// <summary>
		/// An operator for creating a colorPoint object.
		/// </summary>
		/// <remarks>
		/// This operator is designed for use with PointCloud Class, which is written for Raster.ReSampling namespace.
		/// </remarks>
		/// <param name="c">Color Object</param>
		/// <param name="p">Point Object</param>
		/// <returns>A ColoredPoint Object</returns>
        public static ColoredPoint operator +(Color c, Point p)
        {
            return new ColoredPoint(p.X, p.Y, p.Z, c.R, c.G, c.B);
        }

    }
	
    /// <summary>
    /// ColoredPoint class is a special kind of point, to be used in the PointCloud class, which is written for Raster.ReSampling namespace.
    /// </summary>
    /// <seealso cref="Point"/>
    /// <seealso cref="PointCloud"/>
    public class ColoredPoint : Point
    {
    	/// <summary>
    	/// Red value
    	/// </summary>
        public byte R;
        /// <summary>
        /// Green value
        /// </summary>
        public byte G;
        /// <summary>
        /// Blue value
        /// </summary>
        public byte B;

        /// <summary>
        /// Simple constructor, which sets all X,Y,Z offsets to both 0 and R,G,B values to 0 also.
        /// </summary>
        public ColoredPoint()
        {
            X = 0.0;
            Y = 0.0;
            Z = 0.0;
            R = 0;
            G = 0;
            B = 0;
        }
		
        /// <summary>
        /// 2D constructor which sets X,Y offsets and Z offset to 0 with R,G,B values.
        /// </summary>
        /// <param name="x">X offset</param>
        /// <param name="y">Y offset</param>
        /// <param name="r">Red value</param>
        /// <param name="g">Green value</param>
        /// <param name="b">Blue value</param>
        public ColoredPoint(double x, double y, byte r, byte g, byte b)
        {
            X = x;
            Y = y;
            Z = 0.0;
            R = r;
            G = g;
            B = b;
        }

        /// <summary>
        /// 2D constructor which sets X,Y offsets and Z offset to 0 with R,G,B values taken from the given Color object.
        /// </summary>
        /// <param name="x">X offset</param>
        /// <param name="y">Y offset</param>
        /// <param name="c">Color object</param>
        public ColoredPoint(double x, double y, Color c)
        {
            X = x;
            Y = y;
            Z = 0.0;
            R = c.R;
            G = c.G;
            B = c.B;
        }

        /// <summary>
        /// 3D constructor which sets X,Y,Z offsets with R,G,B values.
        /// </summary>
        /// <param name="x">X offset</param>
        /// <param name="y">Y offset</param>
        /// <param name="z">Z offset</param>
        /// <param name="r">Red value</param>
        /// <param name="g">Green value</param>
        /// <param name="b">Blue value</param>
        public ColoredPoint(double x, double y, double z, byte r, byte g, byte b)
        {
            X = x;
            Y = y;
            Z = z;
            R = r;
            G = g;
            B = b;
        }

        /// <summary>
        /// 3D constructor which sets X,Y,Z offsets with R,G,B values taken from the given Color object.
        /// </summary>
        /// <param name="x">X offset</param>
        /// <param name="y">Y offset</param>
        /// <param name="z">Z offset</param>
        /// <param name="c">Color object</param>
        public ColoredPoint(double x, double y, double z, Color c)
        {
            X = x;
            Y = y;
            Z = z;
            R = c.R;
            G = c.G;
            B = c.B;
        }

    }
}
